<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.10"/>
<title>comm_can.c File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../vesc.jpg"/></td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.10 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="../../modules.html"><span>Modules</span></a></li>
      <li><a href="../../annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="../../files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="../../search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="../../search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="../../files.html"><span>File&#160;List</span></a></li>
      <li><a href="../../globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">comm_can.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;string.h&gt;</code><br />
<code>#include &quot;<a class="el" href="../../d9/d2a/comm__can_8h_source.html">comm_can.h</a>&quot;</code><br />
<code>#include &quot;ch.h&quot;</code><br />
<code>#include &quot;hal.h&quot;</code><br />
<code>#include &quot;<a class="el" href="../../dc/d51/datatypes_8h_source.html">datatypes.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d5/d08/buffer_8h_source.html">buffer.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d4/d38/mcpwm_8h_source.html">mcpwm.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../df/deb/timeout_8h_source.html">timeout.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d5/d90/commands_8h_source.html">commands.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d2/d39/app_8h_source.html">app.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../dc/de6/crc_8h_source.html">crc.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d3/d76/packet_8h_source.html">packet.h</a>&quot;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a61645a9be277f9ca6bd9e62eae93f852"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#a61645a9be277f9ca6bd9e62eae93f852">CANDx</a>&#160;&#160;&#160;CAND1</td></tr>
<tr class="separator:a61645a9be277f9ca6bd9e62eae93f852"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab19460f5b34a355a1a8d644e5e1f774d"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#ab19460f5b34a355a1a8d644e5e1f774d">RX_FRAMES_SIZE</a>&#160;&#160;&#160;100</td></tr>
<tr class="separator:ab19460f5b34a355a1a8d644e5e1f774d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a739a2a1a0047c98ac1b18ecd25dac092"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#a739a2a1a0047c98ac1b18ecd25dac092">RX_BUFFER_SIZE</a>&#160;&#160;&#160;<a class="el" href="../../d3/d76/packet_8h.html#ac3be10b8f0586a71c9082ab78e2b23d1">PACKET_MAX_PL_LEN</a></td></tr>
<tr class="separator:a739a2a1a0047c98ac1b18ecd25dac092"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a302ba7cbfee5982fc40432898ed7413e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#a302ba7cbfee5982fc40432898ed7413e">comm_can_init</a> (void)</td></tr>
<tr class="separator:a302ba7cbfee5982fc40432898ed7413e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7c87045186a1caa3f5bfdd575662ae34"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#a7c87045186a1caa3f5bfdd575662ae34">comm_can_transmit</a> (uint32_t id, uint8_t *data, uint8_t len)</td></tr>
<tr class="separator:a7c87045186a1caa3f5bfdd575662ae34"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a455666cd97a43c5cc47faae48ede921a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#a455666cd97a43c5cc47faae48ede921a">comm_can_send_buffer</a> (uint8_t controller_id, uint8_t *data, unsigned int len, bool send)</td></tr>
<tr class="separator:a455666cd97a43c5cc47faae48ede921a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3f891e2d3bf32446f30cf408608be422"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#a3f891e2d3bf32446f30cf408608be422">comm_can_set_duty</a> (uint8_t controller_id, float duty)</td></tr>
<tr class="separator:a3f891e2d3bf32446f30cf408608be422"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a51aea08052617feacfa5144face7f705"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#a51aea08052617feacfa5144face7f705">comm_can_set_current</a> (uint8_t controller_id, float current)</td></tr>
<tr class="separator:a51aea08052617feacfa5144face7f705"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aabb9e177ea86329e2be041be574216a2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#aabb9e177ea86329e2be041be574216a2">comm_can_set_current_brake</a> (uint8_t controller_id, float current)</td></tr>
<tr class="separator:aabb9e177ea86329e2be041be574216a2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a85f12e68cccc19841a5b16472c39562f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#a85f12e68cccc19841a5b16472c39562f">comm_can_set_rpm</a> (uint8_t controller_id, float rpm)</td></tr>
<tr class="separator:a85f12e68cccc19841a5b16472c39562f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a864403d24c94cc7cfc0f389c24ab616c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#a864403d24c94cc7cfc0f389c24ab616c">comm_can_set_pos</a> (uint8_t controller_id, float pos)</td></tr>
<tr class="separator:a864403d24c94cc7cfc0f389c24ab616c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a666e73b6080965cadc4028050a7742c6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../db/dbf/structcan__status__msg.html">can_status_msg</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#a666e73b6080965cadc4028050a7742c6">comm_can_get_status_msg_index</a> (int index)</td></tr>
<tr class="separator:a666e73b6080965cadc4028050a7742c6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1214fd3165e8db4a0a1a6cd8c12e0dea"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../db/dbf/structcan__status__msg.html">can_status_msg</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/da2/comm__can_8c.html#a1214fd3165e8db4a0a1a6cd8c12e0dea">comm_can_get_status_msg_id</a> (int id)</td></tr>
<tr class="separator:a1214fd3165e8db4a0a1a6cd8c12e0dea"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="a61645a9be277f9ca6bd9e62eae93f852"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define CANDx&#160;&#160;&#160;CAND1</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a739a2a1a0047c98ac1b18ecd25dac092"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define RX_BUFFER_SIZE&#160;&#160;&#160;<a class="el" href="../../d3/d76/packet_8h.html#ac3be10b8f0586a71c9082ab78e2b23d1">PACKET_MAX_PL_LEN</a></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="ab19460f5b34a355a1a8d644e5e1f774d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define RX_FRAMES_SIZE&#160;&#160;&#160;100</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a1214fd3165e8db4a0a1a6cd8c12e0dea"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="../../db/dbf/structcan__status__msg.html">can_status_msg</a>* comm_can_get_status_msg_id </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Get status message by id.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">id</td><td>Id of the controller that sent the status message.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The message or 0 for an invalid id. </dd></dl>

</div>
</div>
<a class="anchor" id="a666e73b6080965cadc4028050a7742c6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="../../db/dbf/structcan__status__msg.html">can_status_msg</a>* comm_can_get_status_msg_index </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>index</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Get status message by index.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">index</td><td>Index in the array</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The message or 0 for an invalid index. </dd></dl>

</div>
</div>
<a class="anchor" id="a302ba7cbfee5982fc40432898ed7413e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void comm_can_init </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a455666cd97a43c5cc47faae48ede921a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void comm_can_send_buffer </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>controller_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>send</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Send a buffer up to RX_BUFFER_SIZE bytes as fragments. If the buffer is 6 bytes or less it will be sent in a single CAN frame, otherwise it will be split into several frames.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">controller_id</td><td>The controller id to send to.</td></tr>
    <tr><td class="paramname">data</td><td>The payload.</td></tr>
    <tr><td class="paramname">len</td><td>The payload length.</td></tr>
    <tr><td class="paramname">send</td><td>If true, this packet will be passed to the send function of commands. Otherwise, it will be passed to the process function. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a51aea08052617feacfa5144face7f705"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void comm_can_set_current </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>controller_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>current</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="aabb9e177ea86329e2be041be574216a2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void comm_can_set_current_brake </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>controller_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>current</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a3f891e2d3bf32446f30cf408608be422"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void comm_can_set_duty </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>controller_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>duty</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a864403d24c94cc7cfc0f389c24ab616c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void comm_can_set_pos </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>controller_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>pos</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a85f12e68cccc19841a5b16472c39562f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void comm_can_set_rpm </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>controller_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>rpm</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a7c87045186a1caa3f5bfdd575662ae34"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void comm_can_transmit </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
</div><!-- contents -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://github.com/joshdellay" target="_new">Josh Dellay</a>